#pragma once

#include <string>
#include <memory>
#include <functional>
#include "mongoose.h"

using namespace std;

struct WsRequestMsg
{
    mg_connection *wsConnection = nullptr;
    string receiveMsg = "";
};

using WsCbFun = std::function<void(shared_ptr<WsRequestMsg> &)>;

class IWebsocketServer
{
public:
    IWebsocketServer(){}
    virtual ~IWebsocketServer() {}
    virtual bool startWsServer(int port) = 0;
    virtual bool startWssServer(int port, string certPath, string keyPath) = 0;
    virtual void setWsMsgCbFun(WsCbFun fun) = 0;
    virtual void setWsConnectCbFun(WsCbFun fun) = 0;
    virtual void setWsCloseCbFun(WsCbFun fun) = 0;
    virtual bool sendMsg(shared_ptr<WsRequestMsg> wsRequestMsg, const string &msg) = 0;
    virtual bool stop() = 0;
    virtual bool run() = 0;
};

